package org.bspv.pharma.business.impl;

import java.util.List;

import org.bspv.pharma.business.PlaceManagementBusinessService;
import org.bspv.pharma.manager.PlaceManager;
import org.bspv.pharma.model.Place;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 
 * @author guillaume
 * 
 */
@Service(value = "placeManagementBusinessService")
public class PlaceManagementBusinessServiceImpl implements PlaceManagementBusinessService {
    
    /**
     * Logger.
     */
    private final static Logger LOGGER = LoggerFactory.getLogger(PlaceManagementBusinessServiceImpl.class);

    /**
     * Service basique de gestion des emplacements.
     */
    @Autowired
    private PlaceManager placeManager;

    /**
     * @param placeManager
     *            the placeManager to set
     */
    public void setPlaceManager(PlaceManager placeManager) {
        this.placeManager = placeManager;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Place findPlaceByCode(String placeCode) {
        return placeManager.findByCode(placeCode);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public List<Place> findTopPlaces() {
        return placeManager.findTopPlaces();
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public List<Place> findSubPlaces(String placeCode) {
        Place parent = placeManager.findByCode(placeCode);
        return placeManager.findAllValidChildren(parent);
    }

}
